{#
/*
 * This file is part of the ProductReview plugin
 *
 * Copyright (C) 2016 LOCKON CO.,LTD. All Rights Reserved.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
#}
{#
[商品管理]-[商品レビュー]-[一覧・検索]画面
#}

{% extends '@admin/default_frame.twig' %}

{% set menus = ['product', 'product_review'] %}
{% block title %}{{ 'product_review.admin.product_review.title'|trans }}{% endblock %}
{% block sub_title %}{{ 'product_review.admin.product_review.sub_title'|trans }}{% endblock %}

{% form_theme searchForm '@admin/Form/bootstrap_4_layout.html.twig' %}

{% block stylesheet %}
    <link rel="stylesheet" href="{{ asset('assets/css/tempusdominus-bootstrap-4.min.css', 'admin') }}">
    <style type="text/css">
        .datepicker-days th.dow:first-child,
        .datepicker-days td:first-child {
            color: #f00;
        }

        .datepicker-days th.dow:last-child,
        .datepicker-days td:last-child {
            color: #00f;
        }
    </style>
{% endblock stylesheet %}

{% block javascript %}
    <script>
        $(function() {
            if ($('[type="date"]').prop('type') != 'date') {
                // input type属性でdateが利用できるかどうか(カレンダー表示できないブラウザ対応)
                $.when(
                    $.getScript("{{ asset('assets/js/vendor/moment.min.js', 'admin') }}"),
                    $.getScript("{{ asset('assets/js/vendor/moment-with-locales.min.js', 'admin') }}"),
                    $.getScript("{{ asset('assets/js/vendor/tempusdominus-bootstrap-4.min.js', 'admin') }}")
                ).done(function() {
                    $('input[id$=_review_start]').datetimepicker({
                        locale: '{{ eccube_config.locale }}',
                        format: 'YYYY-MM-DD',
                        useCurrent: false,
                        buttons: {
                            showToday: true,
                            showClose: true
                        }
                    });
                    $('input[id$=_review_end]').datetimepicker({
                        locale: '{{ eccube_config.locale }}',
                        format: 'YYYY-MM-DD',
                        useCurrent: false,
                        buttons: {
                            showToday: true,
                            showClose: true
                        }
                    });
                });
            }
        });
    </script>
{% endblock javascript %}

{% block main %}
    <!--検索条件設定テーブルここから-->
    <div class="c-outsideBlock">
        <form name="search_form" id="search_form" method="post" action="">
            {{ form_widget(searchForm._token) }}
            <div class="c-outsideBlock__contents">
                <div class="row justify-content-start">
                    <div class="col-6">
                        <div class="mb-2">
                            <label class="col-form-label">{{ 'product_review.admin.product_review.search_multi'|trans }}</label>
                            {{ form_widget(searchForm.multi) }}
                            {{ form_errors(searchForm.multi) }}
                        </div>
                        <div class="d-inline-block mb-3" data-toggle="collapse" href="#searchDetail"
                             aria-expanded="false" aria-controls="searchDetail"><a><i
                                        class="fa fa-plus-square-o font-weight-bold mr-1"></i><span
                                        class="font-weight-bold">{{ 'product_review.admin.product_review.search_detail'|trans }}</span></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="c-subContents collapse ec-collapse" id="searchDetail">
                <div class="row mb-2">
                    <div class="col-6 col-sm-4">
                        <label>{{ form_label(searchForm.product_name) }}</label>
                        <div class="form-group">
                            {{ form_widget(searchForm.product_name) }}
                            {{ form_errors(searchForm.product_name) }}
                        </div>
                    </div>
                    <div class="col-6 col-sm-4">
                        <label>{{ form_label(searchForm.product_code) }}</label>
                        <div class="form-group">
                            {{ form_widget(searchForm.product_code) }}
                            {{ form_errors(searchForm.product_code) }}
                        </div>
                    </div>
                    <div class="col-6 col-sm-4">
                        <label>{{ form_label(searchForm.recommend_level) }}</label>
                        <div class="form-group">
                            {{ form_widget(searchForm.recommend_level) }}
                            {{ form_errors(searchForm.recommend_level) }}
                        </div>
                    </div>
                    <div class="col-6 col-sm-4">
                        <label>{{ 'product_review.admin.product_review.search_posted_date'|trans }}</label>
                        <div class="form-group range">
                            {{ form_widget(searchForm.review_start) }}{{ form_errors(searchForm.review_start) }} ～ {{ form_widget(searchForm.review_end) }}{{ form_errors(searchForm.review_end) }}
                        </div>
                    </div>
                    <div class="col-6 col-sm-4">
                        <label>{{ form_label(searchForm.sex) }}</label>
                        <div class="form-group">
                            {{ form_widget(searchForm.sex) }}
                            {{ form_errors(searchForm.sex) }}
                        </div>
                    </div>
                    <div class="col-6 col-sm-4">
                        <label>{{ form_label(searchForm.status) }}</label>
                        <div class="form-group">
                            {{ form_widget(searchForm.status) }}
                            {{ form_errors(searchForm.status) }}
                        </div>
                    </div>
                </div>
                <div class="d-block text-center">
                    <button class="btn btn-ec-regular search-clear"
                            type="button">{{ 'product_review.admin.product_review.search_clear'|trans }}</button>
                </div>
            </div><!-- /.col -->
            <div class="c-outsideBlock__contents mb-5">
                <button class="btn btn-ec-conversion px-5"
                        type="submit">{{ 'product_review.admin.product_review.search_button'|trans }}</button>
                {% if pagination %}
                    <span id="search-result"
                          class="font-weight-bold ml-2">{{ 'product_review.admin.product_review.search_result_count'|trans({"%count%":pagination.totalItemCount}) }}</span>
                {% endif %}
            </div>
            <div class="c-outsideBlock__contents mb-5">
                {{ include('@admin/search_items.twig', { 'form': searchForm }, ignore_missing = true) }}
            </div>
        </form>
    </div>
    <!--検索条件設定テーブルここまで-->
    <div class="c-contentsArea__cols">
        <div class="c-contentsArea__primaryCol">
            <div class="c-primaryCol">
                {% if pagination and pagination.totalItemCount %}

                <div class="row justify-content-between mb-2">
                    <div class="col-6">
                        &nbsp;
                    </div>
                    <div class="col-5 text-right">
                        <div class="d-inline-block mr-2">
                            <div>
                                <select class="custom-select" onchange="location = this.value;">
                                    {% for pageMax in pageMaxis %}
                                        <option {% if pageMax.name == page_count %}selected=""{% endif %}
                                                value="{{ path('product_review_admin_product_review_page', {'page_no': 1, 'page_count': pageMax.name}) }}">{{ 'product_review.admin.product_review.diaply_count'|trans({'%count%' : pageMax.name}) }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                        <div class="d-inline-block">
                            <div class="btn-group" role="group">
                                <button class="btn btn-ec-regular" type="button"
                                        onclick='location.href="{{ url('product_review_admin_product_review_download') }}"'>
                                    <i
                                            class="fa fa-cloud-download mr-1 text-secondary"></i><span>{{ 'product_review.admin.product_review.csv_download'|trans }}</span>
                                </button>
                                <button class="btn btn-ec-regular" type="button"
                                        onclick='location.href="{{ url('admin_setting_shop_csv', { id : CsvType.id }) }}"'>
                                    <i class="fa fa-cog mr-1 text-secondary"></i><span>{{ 'product_review.admin.product_review.csv_download_setting'|trans }}</span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card rounded border-0 mb-4">
                    <div class="card-body p-0">
                        <table class="table table-sm">
                            <thead>
                            <tr>
                                <th class="text-center">ID</th>
                                <th>{{ 'product_review.admin.product_review.th_posted_date'|trans }}</th>
                                <th>{{ 'product_review.admin.product_review.th_contributor'|trans }}</th>
                                <th>{{ 'product_review.admin.product_review.th_product_name'|trans }}</th>
                                <th>{{ 'product_review.admin.product_review.th_title'|trans }}</th>
                                <th>{{ 'product_review.admin.product_review.th_level'|trans }}</th>
                                <th>{{ 'product_review.admin.product_review.th_status'|trans }}</th>
                                <th>&nbsp;</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for Review in pagination %}
                                <tr>
                                    <td class="text-center">{{ Review.id }}</td>
                                    <td>{{ Review.create_date|date_min }}</td>
                                    <td>{{ Review.reviewer_name }}</td>
                                    <td>{{ Review.Product.name }}</td>
                                    <td>
                                        <a href="{{ url('product_review_admin_product_review_edit', { id : Review.id }) }}">{{ Review.title }}</a>
                                    </td>
                                    <td>{% for i in 1..Review.recommend_level %}★{% endfor %}</td>
                                    <td>{{ Review.status }}</td>
                                    <td class="icon_edit">
                                        <div class="col-auto text-right">
                                            <a href="{{ url('product_review_admin_product_review_edit', { id : Review.id }) }}"
                                               class="btn btn-ec-actionIcon mr-3 action-edit"
                                               data-toggle="tooltip"
                                               data-placement="top" title=""
                                               data-original-title=""><i class="fa fa-pencil fa-lg text-secondary"></i></a>

                                            <a
                                                    class="btn btn-ec-actionIcon mr-3"
                                                    data-toggle="modal"
                                                    data-target="#confirmModal-{{ Review.id }}"
                                                    data-toggle="tooltip"
                                                    data-placement="top"><i
                                                        class="fa fa-close fa-lg text-secondary"></i></a>
                                        </div>
                                        <div class="modal fade" id="confirmModal-{{ Review.id }}" tabindex="-1"
                                             role="dialog"
                                             aria-labelledby="confirmModal-{{ Review.id }}" aria-hidden="true">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title font-weight-bold">
                                                            {{ 'product_review.admin.product_review.delete_confirm_title'|trans }}</h5>
                                                        <button class="close" type="button"
                                                                data-dismiss="modal"
                                                                aria-label="Close"><span
                                                                    aria-hidden="true">×</span>
                                                        </button>
                                                    </div>
                                                    <div class="modal-body text-left">
                                                        <p class="text-left">
                                                            {{ 'product_review.admin.product_review.delete_confirm_message'|trans }}</p>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button class="btn btn-ec-sub" type="button"
                                                                data-dismiss="modal">{{ 'product_review.admin.product_review.delete_cancel'|trans }}
                                                        </button>
                                                        <a
                                                                href="{{ url('product_review_admin_product_review_delete', { id : Review.id }) }}"
                                                                class="btn btn-ec-delete"
                                                                data-confirm="false"
                                                                {{ csrf_token_for_anchor() }}
                                                                data-method="delete">
                                                            {{ 'product_review.admin.product_review.delete'|trans }}
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>

                    <div class="row justify-content-md-center mb-4">
                        {% if pagination|length > 0 %}
                            {% include "@admin/pager.twig" with { 'pages' : pagination.paginationData, 'routes' : 'product_review_admin_product_review_page' } %}
                        {% endif %}
                    </div>
                    {% elseif has_errors %}
                        <div class="card rounded border-0">
                            <div class="card-body p-4">
                                <div class="text-center text-muted mb-4 h5">{{ 'product_review.admin.product_review.search_invalid_condition'|trans }}</div>
                                <div class="text-center text-muted">{{ 'product_review.admin.product_review.search_change_condition_and_retry'|trans }}</div>
                            </div>
                        </div>
                    {% else %}
                        <div class="card rounded border-0">
                            <div class="card-body p-4">
                                <div class="text-center text-muted mb-4 h5">{{ 'product_review.admin.product_review.search_no_result'|trans }}</div>
                                <div class="text-center text-muted">{{ 'product_review.admin.product_review.search_change_condition_and_retry'|trans }}</div>
                                <div class="text-center text-muted">{{ 'product_review.admin.product_review.search_try_detail_condition'|trans }}</div>
                            </div>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}
